package src.leetcode.dp.simple_0070;

public class climbStairs {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.climbStairs(3));
    }
}

class Solution {
    public int climbStairs(int n) {
        // 定义dp数组
        int[] dp = new int[n + 1];
        // 初始化dp数组
        dp[0] = 1;
        dp[1] = 1;
        // 遍历数组
        for (int i = 2; i <= n; i++) {
            // 状态转移方程
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        // 返回结果
        return dp[n];
    }
}
